package com.gitee.genshin.analyse.data.service;

import cn.hutool.log.Log;
import com.gitee.genshin.analyse.data.GenshinDataService;

/**
 * @author hongda.li@dlmu.qq.com 2022/7/13 15:55
 */
public class AverageService extends GenshinDataService {
    @Override
    public void doService() {
        RANK_TYPE5.forEach((type, list) -> {
            int max = list.get(0);
            int min = list.get(0);
            int sum = 0;
            for (Integer i : list) {
                sum = sum + i;
                max = Math.max(max, i);
                min = Math.min(min, i);
            }
            int avg = sum / list.size();
            Log.get().info("[{}]平均抽出五星次数[{}]", type.getName(), avg);
            write("[{}]平均抽出五星次数[{}]", type.getName(), avg);

            Log.get().info("[{}]最多抽出五星次数[{}]", type.getName(), max);
            write("[{}]最多抽出五星次数[{}]", type.getName(), max);

            Log.get().info("[{}]最少抽出五星次数[{}]", type.getName(), min);
            write("[{}]最少抽出五星次数[{}]", type.getName(), min);
        });
    }
}
